class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    @classmethod
    def from_birth_year(cls, name, birth_year):
        current_year = 2025
        age = current_year - birth_year
        return cls(name, age)


# 使用工厂方法创建实例
person = Person.from_birth_year("Alice", 1995)
print(person.name, person.age)  # Alice 30
